use axum_app_macro::EnumExt;

#[derive(Debug, EnumExt)]
pub enum Status {
    #[attrs(label = "激活", code = "ACTIVE")]
    Active,
    #[attrs(label = "未激活")]
    Inactive,
}

#[test]
fn test_enum_ext() {
    let label = Status::Active.label();
    assert_eq!("激活", label.as_str());

    let code = Status::Inactive.code();
    assert_eq!("Inactive", code.as_str());

    let code = Status::Active.code();
    assert_eq!("ACTIVE", code.as_str());

    let json = Status::Active.to_json();
    assert_eq!(
        r#"{ "code": "ACTIVE", "name": "Active", "label": "激活" }"#,
        json.as_str()
    );
}
